package com.two.screen.water.balance.bean.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;


import com.two.screen.water.balance.utils.CommUtils;

import org.greenrobot.greendao.database.Database;

public class MySqlLiteOpenHelper extends DaoMaster.OpenHelper {
    public MySqlLiteOpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory) {
        super(context, name, factory);
    }

    @Override
    public void onUpgrade(Database db, int oldVersion, int newVersion) {
        CommUtils.Companion.println("noel:", "oldVersion:" + oldVersion + ",newVersion" + newVersion);
//        MigrationHelper.getInstance().migrate(db, UserDBDao.class);
//
//        MigrationHelper.getInstance().migrate(db, CateDBDao.class);
//        MigrationHelper.getInstance().migrate(db, ProductDBDao.class);
//
//        MigrationHelper.getInstance().migrate(db, OrderDBDao.class);
//        MigrationHelper.getInstance().migrate(db, OrderProductDBDao.class);


        MigrationHelper.migrate(db, new MigrationHelper.ReCreateAllTableListener() {
            @Override
            public void onCreateAllTables(Database db, boolean ifNotExists) {
                DaoMaster.createAllTables(db, ifNotExists);
            }

            @Override
            public void onDropAllTables(Database db, boolean ifExists) {
                DaoMaster.dropAllTables(db, ifExists);
            }
        }, UserDBDao.class, CateDBDao.class, ProductDBDao.class, OrderDBDao.class, OrderProductDBDao.class);

    }

}
